import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Rank from '../views/Home/Rank.vue'
import Search from '../views/Home/Search.vue'
import Recommend from '../views/Home/Recommend.vue'
// import Newest_music from '../views/Home/Recommand/newest_music.vue'
import Album from '../views/Album.vue'
import Play_detail from '../views/Home/play_detail/play_detail.vue'

Vue.use(VueRouter)

const routes = [{
		path: '/',
		name: 'Home',
		// alias:'/home',
		component: Home,	
		redirect: "/recommend",
		children: [{
				path: "recommend",
				name: "Recommend",
				component: Recommend,
			},
			{
				path: "rank",
				name: "Rank",
				component: Rank,
			},
			{
				path: "search",
				name: "Search",
				component: Search,
			}
		]
	},
	// {
	// 	path: '/about',
	// 	name: 'About',
	// 	// route level code-splitting
	// 	// this generates a separate chunk (about.[hash].js) for this route
	// 	// which is lazy-loaded when the route is visited.
	// 	component: () => import( /* webpackChunkName: "about" */ '../views/About.vue'),
	// 	children: [{
	// 			path: "recommend",
	// 			name: "Recommend",
	// 			component: Recommend,
	// 		},
	// 		{
	// 			path: "rank",
	// 			name: "Rank",
	// 			component: Rank,
	// 		},
	// 		{
	// 			path: "search",
	// 			name: "Search",
	// 			component: Search,
	// 		}
	// 	]

	// },
	{
		path: '/album/:id',
		name: 'Album',
		component: Album
	},
	{
		path: '/play_detail',
		name: 'Play_detail',
		component: Play_detail
	}
]

const router = new VueRouter({
	routes
})


router.afterEach((to, from) => {
	console.log('跳转完成', to, from);
	window.scrollTo({
		left: 0,
		top: 0,
		behavior: 'smooth'
	})
})

export default router
